package zjhr.com.service.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import zjhr.com.mapper.ZjInmoneyMapper;
import zjhr.com.pojo.EasyUIPageQuery;
import zjhr.com.pojo.ZjInmoney;
import zjhr.com.pojo.ZjInmoneyExample;
import zjhr.com.service.InMoneyService;
import zjhr.com.utils.IDUtils;
@Service
public class InMoneyServiceImpl implements InMoneyService {
	@Autowired
	private ZjInmoneyMapper inMoneyMapper;
	
	//添加进账信息
	@Override
	public void save(ZjInmoney inMoney) {
		inMoney.setInid(IDUtils.genImageName());
		inMoneyMapper.insert(inMoney);
	}
	//分页
	@Override
	public EasyUIPageQuery pageQuery(Integer page, Integer rows) {
		ZjInmoneyExample example = new ZjInmoneyExample();
		// TODO Auto-generated method stub
		int total = inMoneyMapper.countByExample(example);
		int start = (page-1)*rows;
		List<ZjInmoney> list = inMoneyMapper.selectPageQuery(start, rows.intValue());
		EasyUIPageQuery pageQuery = new EasyUIPageQuery(total, list);
		return pageQuery;
	}
	//修改
	@Override
	public void edit(ZjInmoney inMoney) {
		
		inMoneyMapper.updateByPrimaryKey(inMoney);
	}
	//删除
	@Override
	public void delete(String ids) {
		String[] id = ids.split(",");
		for (String inid : id) {
			inMoneyMapper.deleteByPrimaryKey(inid);
		}
		
	}
	@Override
	public List<ZjInmoney> findAll(String beginDate,String endDate) {
		if(StringUtils.isNotBlank(beginDate) && StringUtils.isNotBlank(endDate)){
			List<ZjInmoney> list = inMoneyMapper.selectByDate(beginDate, endDate);
			return list;
		}else{
			return null;
		}
	}
	

}
